package org.example.mybatis.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.example.mybatis.model.UserInfo;

import java.util.List;

@Mapper
public interface IUserInfoMapper1 {

    /*
    * 当查询的条件是数字
    * */
    @Select("select * from userinfo where id = #{id}")
    List<UserInfo> selectUserInfo(Integer id);

    @Select("select * from userinfo where id = ${id}")
    List<UserInfo> selectUserInfo1(Integer id);

    /*
     * 当查询的条件是字符串
     * $会出现错误，进行的是字符串拼接，缺少“”
     * #进行的是复制，会自带“”
     * */

    @Select("select * from userinfo where id = #{username}")
    List<UserInfo> selectUserInfo2(String username);

    @Select("select * from userinfo where id = ${username}")
    List<UserInfo> selectUserInfo3(String username);


    @Select("select * from userinfo where id =' ${username}'")
    List<UserInfo> selectUserInfo4(String username);

//    $存在安全问题
    @Select("select * from userinfo where id =' ${username}'")
    List<UserInfo> selectUserInfo5(String username);

}
